#ifndef _COMINICATE_H
#define _COMINICATE_H
#include "spi_cc1101.h"
#include "rfProtocol.h"
#include "USART.h"

/***************定义设备类型****************/
//#define TYPE_SLAVE
#define CC_BASE
#define UPDATA_ADD_RSSI_LQI
/*****************************************/

/***************配置网络参数****************/
#define BASESYNC 0x1234
/*****************************************/

/***************设备参数****************/
#ifdef CC_BASE
#define ADDR_BASE 5
#define BASECHANNEL 110
#define DEVICELEN 512
extern uint8_t deviCmdBuf[DEVICELEN];//存储多少个标签
void updataRecord(void);
void recvOkAndHandle(void);
void cominicateDataInit(void);
#endif

#ifdef TYPE_SLAVE
extern uint8_t channelBuf[5];
extern int32_t lRecvDeviceAdressErrorTimes;
extern int32_t lRecvCmdTimes;
extern int32_t lNewChannelTimes;
extern int32_t lWaitChannelTimes;
extern uint16_t deviceAddr;
#endif
/*****************************************/

extern baseToServerCmdDef baseToServerCmd;
extern baseToSlaveCmdDef baseToSlaveCmd;
extern slaveToBaseCmdDef slaveToBaseCmd;
extern serverToBaseCmdDef serverToBaseCmd;
extern rfMetricCmdDef tCmdMertric;

uint8_t getSumChekVal(uint8_t *val, uint8_t len);
uint32_t getTimeDifference(uint32_t recordtime, uint32_t realTime);

#endif



